package com.xiaowei.gym.gymjsp.ware.service.impl;

import com.xiaowei.gym.gymjsp.ware.dao.PersonnelDao;
import com.xiaowei.gym.gymjsp.ware.dao.impl.PersonnelDaoImpl;
import com.xiaowei.gym.gymjsp.ware.entity.PersonnelEntity;
import com.xiaowei.gym.gymjsp.ware.service.PersonnelService;

import java.util.List;

public class PersonnelServiceImpl implements PersonnelService {

    private PersonnelDao personnelDao;

    public PersonnelServiceImpl() {
        personnelDao = new PersonnelDaoImpl();
    }

    @Override
    public List<PersonnelEntity> getPersonnelAll() {
        return personnelDao.getPersonnelAll();
    }

    @Override
    public int getSalaryCount() {

        return 0;
    }

    @Override
    public List<PersonnelEntity> getPersonnelList(String name, int currentPageNo, Integer pageSize) {
        return personnelDao.getPersonnelList(name,currentPageNo,pageSize);
    }

    @Override
    public boolean delPersonnel(Integer[] delId) {
        Integer[] integers = personnelDao.delPersonnel(delId);
        if (integers.length > 0 || integers != null){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean addPersonnel(PersonnelEntity personnelEntity) {

        int personnel = personnelDao.createPersonnel(personnelEntity);
        if (personnel > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean modify(PersonnelEntity personnelEntity) {
        int i = personnelDao.updatePersonnel(personnelEntity);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public PersonnelEntity getByid(String sid) {
        return personnelDao.getByid(sid);
    }
}
